{% extends "master.html" %}
{% block subtitle %} - 商品管理 - 创建新商品{% endblock %}

{% block extCSS %}
<style type="text/css">
    .atmtemplate{
        display : none;
    }
    
    .imgtemplate{
        display : none;
    }
</style>
{% endblock %}


{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
        
    function toSubmit(){
        var msg = [];
        clearMsg();
        $(".err").removeClass('err');
        
        if(!$("#name").val()){
            msg.push('请填写商品名称！');
            $("#name").addClass('err');
        }
        
        if(!$("#pPrice").val()){
            msg.push('请填写商品买入价格！');
            $("#pPrice").addClass('err');
        }
        
        if(!$("#sPrice").val()){
            msg.push('请填写商品买出价格！');
            $("#sPrice").addClass('err');
        }
        
        if(msg.length > 0){
            alertError(msg);
            return false;
        }else{
            $("form").submit();
        }
    }
    
    function toCancel(){
        redirect_alert("{{MSG_LEAVE_WITHOUT_SAVING}}","{{url_for('bpPdt.view')}}")
    }          
        
//]]>
</script>
{% endblock %}


{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpMas.view')}}">基础信息</a></li>
          <li><a href="{{url_for('bpPdt.view')}}">商品管理</a></li>
          <li class="active">创建新商品</li>
        </ol>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button type="button" class="btn btn-primary" onclick="toSubmit()">{{BTN_SUBMIT}}</button></div>
            <div class="btn-group"><button type="button" class="btn btn-inverse" onclick="toCancel()">{{BTN_CANCEL}}</button></div>
        </div>
    </div>
    <div class="row">
        <form class="" method='POST' action="{{url_for('bpPdt.view',action='add')}}" enctype="multipart/form-data">
        <fieldset>
            <legend>商品详情</legend>
            <div class="col-md-4">
                <div class="control-group">
                  <label class="control-label" for="name">商品名称<span style='color:red'>*</span></label>
                  <div class="controls">
                      <input type="text" name="name" id="name" value=""/>
                  </div>
                </div>       
                <div class="control-group">
                  <label class="control-label" for="typeID">商品类型<span style='color:red'>*</span></label>
                  <div class="controls">
                      <select id="typeID" name="typeID">
                          <option value=""></option>
                          {% for p in pts %}
                              <option value="{{p.id}}">{{p}}</option>
                          {% endfor %}
                      </select>
                      {% if getAllPermission(['MASTER_CREATE',])%}
                            <a href="#" onclick="refreshMaster('typeID','ProductType')"><i class="glyphicon glyphicon-refresh"></i></a>
                            <a target="_blank" href="{{url_for('bpMas.view',action='add',t='PT')}}"><i class="glyphicon glyphicon-plus"></i></a>
                      {% endif %}
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="shapID">商品形状</label>
                  <div class="controls">
                      <select id="shapID" name="shapID">
                          <option value=""></option>
                          {% for p in getMaster('ProductShap') %}
                              <option value="{{p.id}}">{{p}}</option>
                          {% endfor %}
                      </select>
                      {% if getAllPermission(['MASTER_CREATE',])%}
                            <a href="#" onclick="refreshMaster('shapID','ProductShap')"><i class="glyphicon glyphicon-refresh"></i></a>
                            <a target="_blank" href="{{url_for('bpMas.view',action='add',t='PS')}}"><i class="glyphicon glyphicon-plus"></i></a>
                        {% endif %}
                  </div>
                </div>         
                <div class="control-group">
                  <label class="control-label" for="seriesID">商品系列</label>
                  <div class="controls">
                      <select id="seriesID" name="seriesID">
                          <option value=""></option>
                          {% for p in getMaster('ProductSeries') %}
                              <option value="{{p.id}}">{{p}}</option>
                          {% endfor %}
                      </select>
                      {% if getAllPermission(['MASTER_CREATE',])%}
                            <a href="#" onclick="refreshMaster('seriesID','ProductSeries')"><i class="glyphicon glyphicon-refresh"></i></a>
                            <a target="_blank" href="{{url_for('bpMas.view',action='add',t='PSR')}}"><i class="glyphicon glyphicon-plus"></i></a>
                        {% endif %}
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="pPrice">建议采购价格<span style='color:red'>*</span></label>
                  <div class="controls">
                      <input type="text" name="pPrice" id="pPrice" value="" class="num"/>
                  </div>
                </div>
                
                <div class="control-group">
                  <label class="control-label" for="sPrice">建议销售价格<span style='color:red'>*</span></label>
                  <div class="controls">
                      <input type="text" name="sPrice" id="sPrice" value="" class="num"/>
                  </div>
                </div>
                
                <div class="control-group">
                  <label class="control-label" for="styleNo">款号</label>
                  <div class="controls">
                      <input type="text" name="styleNo" id="styleNo" value=""/>
                  </div>
                </div>
                
            </div>
            <div class="col-md-4">
            
                <div class="control-group">
                  <label class="control-label" for="weight">重量</label>
                  <div class="controls">
                      <input type="text" name="weight" id="weight" value=""/>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="weight">长度</label>
                  <div class="controls">
                      <input type="text" name="length" id="length" value=""/>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="weight">宽度</label>
                  <div class="controls">
                      <input type="text" name="width" id="width" value=""/>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="weight">高度</label>
                  <div class="controls">
                      <input type="text" name="height" id="height" value=""/>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="length">手寸长度</label>
                  <div class="controls">
                      <input type="text" name="length" id="length" value=""/>
                  </div>
                </div>
                
                <div class="control-group">
                  <label class="control-label" for="clarity">净度</label>
                  <div class="controls">
                      <input type="text" name="clarity" id="clarity" value=""/>
                  </div>
                </div>
                
                <div class="control-group">
                  <label class="control-label" for="color">颜色</label>
                  <div class="controls">
                      <input type="text" name="color" id="color" value=""/>
                  </div>
                </div>    
            </div>
            <div class="col-md-4">
                <div class="control-group">
                  <label class="control-label" for="goldFineness">金成色</label>
                  <div class="controls">
                      <input type="text" name="goldFineness" id="goldFineness" value=""/>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="certificate">证书号</label>
                  <div class="controls">
                      <input type="text" name="certificate" id="certificate" value=""/>
                  </div>
                </div>
                <div class="control-group">
                    <label class="control-label"><label for="">是否发布到网站</label></label>
                    <div class="controls">
                        <label class="radio"><input type="radio" name="isDeploy" value="1"> 是</label>
                        <label class="radio"><input type="radio" name="isDeploy" value="0" checked="checked"> 否</label>
                    </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="remark">备注</label>
                  <div class="controls">
                      <textarea name="remark" id="remark"></textarea>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="realImgID">缩略图</label>
                  <div class="controls">
                      <ul class="list-unstyled">
                          <li><input type="file" name="realImgID" id="realImgID"/></li>
                      </ul>
                  </div>
                </div>
                 <div class="control-group">
                  <label class="control-label" for="remark">展示图片</label>
                  <div class="controls">
                      <ul id="imgul" class="list-unstyled">
                          <li><input type="file" name="img_10"/><a href="#" onclick="addAtm('imgtemplate','imgmk','#imgul')"><i class="glyphicon glyphicon-plus"></i></a></li>
                          <li class="imgtemplate"><input type="file" name="img_x"/><a href="#" onclick="delAtm(this,'imgmk')"><i class="glyphicon glyphicon-minus"></i></a></li>
                      </ul>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label" for="attachment">附件</label>
                  <div class="controls">
                      <ul id="atmul" class="list-unstyled">
                          <li><input type="file" name="atm_10"/><a href="#" onclick="addAtm('atmtemplate','atmmk','#atmul')"><i class="glyphicon glyphicon-plus"></i></a></li>
                          <li class="atmtemplate"><input type="file" name="atm_x"/><a href="#" onclick="delAtm(this,'atmmk')"><i class="glyphicon glyphicon-minus"></i></a></li>
                      </ul>
                  </div>
                </div>
                
            </div>      
        </fieldset>
        </form>
    </div>
    
   
</div>
{% endblock %}